package com.example.tests;

import org.testng.annotations.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import com.example.fw.ContactObject;
import com.example.fw.Contacts;

public class ContactCreationTests extends TestBase {

	@Test(dataProvider = "contactsFromFile", dataProviderClass = ContactDataGenerator.class)
	public void testValidContactCanBeCreated(ContactObject validContact)
			throws Exception {
		validContact.setFullName(validContact.getFullName());
		Contacts oldList = app.getContactHelper().getContacts();
		app.getContactHelper().createContact(validContact);
		Contacts newList = app.getContactHelper().getContacts();
		assertThat(newList, equalTo(oldList.withAdded(validContact)));
	}

	//@Test
	public void testEmptyContactCanBeCreated() throws Exception {
		ContactObject emptyContact = new ContactObject().setFirstname("")
				.setLastname("").setAddress("").setHome("").setMobile("")
				.setWork("").setEmail("").setEmail2("").setbDay("-")
				.setbMonth("-").setbYear("").setNewGroup("[none]")
				.setAddress2("").setPhone2("");
		emptyContact.setFullName(emptyContact.getFullName());
		Contacts oldList = app.getContactHelper().getContacts();
		app.getContactHelper().createContact(emptyContact);
		Contacts newList = app.getContactHelper().getContacts();
		assertThat(newList, equalTo(oldList.withAdded(emptyContact)));
	}
}
